local yuyan = fk.CreateSkill{
    name = "wk_heg__yuyan",
}

Fk:loadTranslationTable{
    ["wk_heg__yuyan"] = "誉言",
    [":wk_heg__yuyan"] = "①你是与你势力相同且距离为1的角色的“合纵”的合法目标；②当你于回合外获得其他角色的牌后，你可将等量张牌交给当前回合角色，"..
    "若如此做，此回合结束时，若其与你势力相同，你<a href=':ElectedChange'>推举</a>。",

    ["#wk_heg__yuyan-give"] = "誉言：交给 %dest 共计 %arg 张牌",

    ["$wk_heg__yuyan1"] = "君满腹才学，当为国之大器。",
    ["$wk_heg__yuyan2"] = "一腔青云之志，正待梦日之时。",
}

local H = require "packages.ol_hegemony.util"
local HG = require "packages.new_heg_diy_my.util"

yuyan:addEffect(fk.AfterCardsMove,{
  anim_type = "support",
  can_trigger = function (self, event, target, player, data)
    if not player:hasSkill(yuyan.name) or player.room.current == player then return end
    local n = 0
    for _, move in ipairs(data) do
      if move.to and move.to == player and move.from and move.from ~= player and move.toArea == Card.PlayerHand then
        for _, info in ipairs(move.moveInfo) do
          if info.fromArea == Card.PlayerHand or info.fromArea == Card.PlayerEquip then
            n = n + 1
          end
        end
      end
    end
    if n > 0 then
      event:setCostData(self,{ num = n })
      return true
    end
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local current = room.current
    local n = event:getCostData(self).num
    local cards2
    if #player:getCardIds("he") <= n then
      cards2 = player:getCardIds("he")
    else
      cards2 = room:askToCards(player,{
        min_num = n,
        max_num = n,
        include_equip = true,
        skill_name = yuyan.name,
        cancelable = false,
        prompt = "#wk_heg__yuyan-give::"..current.id..":"..n,
      })
    end
    room:moveCardTo(cards2, Card.PlayerHand, current, fk.ReasonGive, yuyan.name, nil, false, player.id)
  end,
})

--可合纵 --需添加状态技 --可合纵 已在ol_hegemony中实现
yuyan:addEffect("allowAlliance",{
  allow_alliance = function(self, from, to)
    return H.compareKingdomWith(from, to) and to:hasShownSkill(yuyan.name) and from:distanceTo(to) == 1
  end,
})

yuyan:addEffect(fk.TurnEnd,{
  mute = true,
  is_delay_effect = true,
  can_trigger = function(self, event, target, player, data)
    return player:usedSkillTimes(yuyan.name, Player.HistoryTurn) > 0 and H.compareKingdomWith(player, player.room.current)
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    HG.DoElectedChange(player.room, player, yuyan.name)
  end,
})

return yuyan